package org.song.videoplayer.rederview;

import android.util.Log;
import android.view.View;

import java.lang.ref.WeakReference;

/**
 * Contact github.com/tohodog
 * 根据缩放模式设置渲染view的大小
 */
public final class MeasureHelper {


    private int mVideoWidth;
    private int mVideoHeight;

    private int mMeasuredWidth;
    private int mMeasuredHeight;



    public void setVideoSize(int videoWidth, int videoHeight) {
        mVideoWidth = videoWidth;
        mVideoHeight = videoHeight;
    }


    /**
     * 根据模式计算视频显示的大小
     */
    public void doMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int width = View.getDefaultSize(mVideoWidth, widthMeasureSpec);
        int height = View.getDefaultSize(mVideoHeight, heightMeasureSpec);


        mMeasuredWidth = width;
        mMeasuredHeight = height;
        Log.e("viewsize", "视频大小 = " + mVideoWidth + "," + mVideoHeight
                + "\n改变后view大小 = " + width + "," + height);

    }

    public int getMeasuredWidth() {
        return mMeasuredWidth;
    }

    public int getMeasuredHeight() {
        return mMeasuredHeight;
    }


}
